using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;

namespace CPlatePrintSys.Application.Converters
{
    /// <summary>
    /// 将字符串转换为Visibility枚举值的转换器
    /// </summary>
    public class StringToVisibilityConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is string stringValue)
            {
                return !string.IsNullOrEmpty(stringValue) ? Visibility.Visible : Visibility.Collapsed;
            }
            return Visibility.Collapsed;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is Visibility visibility)
            {
                return visibility == Visibility.Visible ? "Visible" : "Collapsed";
            }
            return "Collapsed";
        }
    }
} 